﻿using System;
using System.Windows.Forms;
using System.Collections.Generic;
using MediaPortal.GUI.Library;
using MediaPortal.Dialogs;
using OpenSocialPlugin.Providers;
using OpenSocialPlugin.General;
using Facebook = OpenSocialPlugin.Providers.Facebook;

namespace OpenSocialPlugin
{
  public class GUISelector : GUIWindow
  {
    [SkinControlAttribute(101)] protected GUIButtonControl button101=null;
    [SkinControlAttribute(102)] protected GUIButtonControl button102 = null;
    [SkinControlAttribute(103)] protected GUIButtonControl button103 = null;
    [SkinControlAttribute(104)] protected GUIButtonControl button104 = null;
    [SkinControlAttribute(105)] protected GUIButtonControl button105 = null;
    [SkinControlAttribute(106)] protected GUIButtonControl button106 = null;

    private Dictionary<GUIControl, ISocialSite> sites = new Dictionary<GUIControl, ISocialSite>();

    public GUISelector()
    {
        GetID = 30052;
    }

    protected override void OnPageLoad()
    {
        base.OnPageLoad();
        sites.Add(button101, new Hi5());
        sites.Add(button102, new Providers.Facebook());
        sites.Add(button103, new PicasaWeb());
        sites.Add(button104, new Flickr());
        sites.Add(button105, new Photopoints());
        sites.Add(button106, new Photobucke());

        foreach (KeyValuePair<GUIControl, ISocialSite> s in sites)
        {
            ((GUIButtonControl)s.Key).Label = s.Value.ToString();
        }

    }
    public override bool Init()
    {
        return Load(GUIGraphicsContext.Skin + @"\opensocialselector.xml");
    }

    protected override void OnClicked(int controlId, GUIControl control,
      MediaPortal.GUI.Library.Action.ActionType actionType)
    {
        if (sites.ContainsKey(control))
        {
            StaticHelper.SiteProvider = sites[control];
            GUIWindowManager.ActivateWindow(30050);
        }
      base.OnClicked (controlId, control, actionType);
    }

   }

}
